<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FCKTools.RunFunction</title>
	<style type="text/css">

		.Ok
		{
			background-color: green ;
		}

		.Failed
		{
			background-color: red ;
		}

	</style>
	<script src="../../../editor/_source/fckjscoreextensions.js" type="text/javascript"></script>
	<script src="../../../editor/_source/internals/fckbrowserinfo.js" type="text/javascript"></script>
	<script src="../../../editor/_source/internals/fcktools.js" type="text/javascript"></script>
	<script type="text/javascript">

function LoadScript( url )
{
	document.write( '<script type="text/javascript" src="' + url + '"><\/script>' ) ;
}
var sSuffix = FCKBrowserInfo.IsIE ? 'ie' : 'gecko' ;
LoadScript( '../../../editor/_source/internals/fcktools_' + sSuffix + '.js' ) ;

	</script>
	<script type="text/javascript">

window._FCK = 'Main Window' ;

FCKTools.RegisterDollarFunction( window ) ;

window.onload = function()
{
	// Case 1
	FCKTools.RunFunction( MainWindow ) ;
	FCKTools.RunFunction( MainWindowParams, null, [ document.body, 'Test' ] ) ;

	// Case 2
	var o = new Object() ;
	o._FCK = 'Custom Object' ;

	FCKTools.RunFunction( CustomObject, o ) ;
	FCKTools.RunFunction( CustomObjectParams, o, [ document.body, 'Test' ] ) ;

	// Case 3
	var e = $('xElement') ;
	e._FCK = 'Element' ;
	FCKTools.RunFunction( Element, e ) ;
	FCKTools.RunFunction( ElementParams, e, [ document.body, 'Test' ] ) ;
}

function MainWindow()
{
	$('xMainWindow').className = ( this._FCK == 'Main Window' ? 'Ok' : 'Failed' ) ;
}

function MainWindowParams( el, str )
{
	$('xMainWindowParams').className = ( this._FCK == 'Main Window' && el.tagName == 'BODY' && str == 'Test' ? 'Ok' : 'Failed' ) ;
}

function CustomObject()
{
	$('xCustomObject').className = this._FCK == 'Custom Object' ? 'Ok' : 'Failed' ;
}

function CustomObjectParams( el, str )
{
	$('xCustomObjectParams').className = ( this._FCK == 'Custom Object' && el.tagName == 'BODY' && str == 'Test' ? 'Ok' : 'Failed' ) ;
}

function Element()
{
	$('xElement').className = this._FCK == 'Element' ? 'Ok' : 'Failed' ;
}

function ElementParams( el, str )
{
	$('xElementParams').className = ( this._FCK == 'Element' && el.tagName == 'BODY' && str == 'Test' ? 'Ok' : 'Failed' ) ;
}

	</script>
</head>
<body>
	<h1>
		FCKTools.RunFunction</h1>
	<p>
		A green box must appear for each line in this list:
	</p>
	<table align="center">
		<tr><td>Main Window</td><td id="xMainWindow" width="100"></td></tr>
		<tr><td>Main Window + Params</td><td id="xMainWindowParams" width="100"></td></tr>
		<tr><td>Custom Object</td><td id="xCustomObject" width="100"></td></tr>
		<tr><td>Custom Object + Params</td><td id="xCustomObjectParams" width="100"></td></tr>
		<tr><td>Element</td><td id="xElement" width="100"></td></tr>
		<tr><td>Element + Params</td><td id="xElementParams" width="100"></td></tr>
	</table>
</body>
</html>
